import { createApp } from 'vue'
import App from './App.vue'

// 导入初始样式
import '@/styles/common.scss';

import { createPinia } from 'pinia';
import piniaPluginPersistedstate from 'pinia-plugin-persistedstate';
import router from '@/routers/router';

// 导入自定义指令插件
import { imgLazyPlugin } from '@/directives/directive';

// 导入全局组件插件
import { XtxComponentsPlugin } from './components/components';

// 导入ElementPlus图标集
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

// 创建应用实例
const app = createApp(App);
// 应用实例应用Pinia、安装Pinia插件
const pinia = createPinia();
pinia.use(piniaPluginPersistedstate);
app.use(pinia);
// 应用实例应用VueRouter
app.use(router);
// 应用实例挂载到页面
app.mount('#app');
// 安装全局指令
app.use(imgLazyPlugin);
// 安装全局组件
app.use(XtxComponentsPlugin);
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
  }